var APP = require("../../../lib/main/app");
var VALIDATE = require("../../../lib/function/validate");
var UTIL = require("../../../lib/function/util");
var POWER = require("../../../lib/api/power");
var page = {
    subject: null,
    activeIndex: 0,
    footerHeight: null,
    ruid: 888,
    agoraRtc: null,
	uid:null,
	code:null,
    ready: function() {
        var that = this;
		that.uid = api.pageParam.uid;
		that.code = api.pageParam.code;
        that.agoraRtc = api.require('agoraRtc');
        // 头部处理
        var headerHeight = $('#header').height();
        $('body').css('padding-top', headerHeight);
		// POWER.opWithPermission('camera');//相机权限
		// POWER.opWithPermission('microphone');//打开麦克风
		that.initFrame();
    },
    on: function() {
        var that = this;
		// 禁止屏幕休眠
		api.setKeepScreenOn({
		    keepOn: true
		});
		//点击返回
		API.listenEvt('keyback', function() {
			console.log('返回')
			API.sendEvt('CLOSE_AGORARTC',{});
			api.setKeepScreenOn({
			    keepOn: false
			});
		});
        //批量事件start
        var events = [
            //打开页面
            ['#add-channel', function() {
                
            }],
            // 关闭页面
            ['#close', function() {
                
            }],
        ];
        APP.e.more(events);
        //批量事件end
    },
    methods: {
        initFrame: function() {
			var that = this;
			api.openFrame({
			    name: 'videolist',
			    url: './videolist.html',
			    rect: {
			        x: 0,
			        y: 0,
			        w: 'auto',
			        h: 'auto'
			    },
			    pageParam: {
					uid : that.uid,
					code : that.code,
			    }
			});
        }
    }
}
API.run(page);
